#include <QtGui>
#include <QtCore/QTextCodec>
#include <QTranslator>
#include "gv_setuphomedialog.h"
#include "gv_miscnamechangedialog.h"
#include "gv_home.h"
#include "gv_setting.h"

extern GV_Setting *gvsetting;
extern QDialog  *dialog;
GV_NameChangeDialog::GV_NameChangeDialog(QWidget *parent)
       : QDialog(parent)
{
    setupUi(this);

    QTranslator translator;
    translator.load(gvsetting->GV_GetLanguage(),".");
    qApp->installTranslator(&translator);
    reloadtext();

    TimeHintsLabel->setText((QDateTime::currentDateTime().toString("hh:mm:ss")));
    DateHintsLabel->setText((QDateTime::currentDateTime().toString("yyyy-MM-dd")));

    currentNum = 0;
    totalNum = 0;
    newpassword=conformpassword = 0;

    newpasswodButtonEnable = true;

    timer = new QTimer;
    connect(timer,SIGNAL(timeout()),this,SLOT(GV_chTime()));
    connect(SaveButton,SIGNAL(clicked()),this,SLOT(save()));
    connect(CancelButton,SIGNAL(clicked()),this,SLOT(cancel()));
    connect(HelpButton,SIGNAL(clicked()),this,SLOT(cancel()));

    connect(Key0Button,SIGNAL(clicked()),this,SLOT(key0Clicked()));
    connect(Key1Button,SIGNAL(clicked()),this,SLOT(key1Clicked()));
    connect(Key2Button,SIGNAL(clicked()),this,SLOT(key2Clicked()));
    connect(Key3Button,SIGNAL(clicked()),this,SLOT(key3Clicked()));
    connect(Key4Button,SIGNAL(clicked()),this,SLOT(key4Clicked()));
    connect(Key5Button,SIGNAL(clicked()),this,SLOT(key5Clicked()));
    connect(Key6Button,SIGNAL(clicked()),this,SLOT(key6Clicked()));
    connect(Key7Button,SIGNAL(clicked()),this,SLOT(key7Clicked()));
    connect(Key8Button,SIGNAL(clicked()),this,SLOT(key8Clicked()));
    connect(Key9Button,SIGNAL(clicked()),this,SLOT(key9Clicked()));
    connect(KeyAButton,SIGNAL(clicked()),this,SLOT(keyAClicked()));
    connect(KeyBButton,SIGNAL(clicked()),this,SLOT(keyBClicked()));
    connect(KeyCButton,SIGNAL(clicked()),this,SLOT(keyCClicked()));
    connect(KeyDButton,SIGNAL(clicked()),this,SLOT(keyDClicked()));
    connect(KeyEButton,SIGNAL(clicked()),this,SLOT(keyEClicked()));
    connect(KeyFButton,SIGNAL(clicked()),this,SLOT(keyFClicked()));
    connect(KeyGButton,SIGNAL(clicked()),this,SLOT(keyGClicked()));
    connect(KeyHButton,SIGNAL(clicked()),this,SLOT(keyHClicked()));
    connect(KeyIButton,SIGNAL(clicked()),this,SLOT(keyIClicked()));
    connect(KeyJButton,SIGNAL(clicked()),this,SLOT(keyJClicked()));
    connect(KeyKButton,SIGNAL(clicked()),this,SLOT(keyKClicked()));
    connect(KeyLButton,SIGNAL(clicked()),this,SLOT(keyLClicked()));
    connect(KeyMButton,SIGNAL(clicked()),this,SLOT(keyMClicked()));
    connect(KeyNButton,SIGNAL(clicked()),this,SLOT(keyNClicked()));
    connect(KeyOButton,SIGNAL(clicked()),this,SLOT(keyOClicked()));
    connect(KeyPButton,SIGNAL(clicked()),this,SLOT(keyPClicked()));
    connect(KeyQButton,SIGNAL(clicked()),this,SLOT(keyQClicked()));
    connect(KeyRButton,SIGNAL(clicked()),this,SLOT(keyRClicked()));
    connect(KeySButton,SIGNAL(clicked()),this,SLOT(keySClicked()));
    connect(KeyTButton,SIGNAL(clicked()),this,SLOT(keyTClicked()));
    connect(KeyUButton,SIGNAL(clicked()),this,SLOT(keyUClicked()));
    connect(KeyVButton,SIGNAL(clicked()),this,SLOT(keyVClicked()));
    connect(KeyWButton,SIGNAL(clicked()),this,SLOT(keyWClicked()));
    connect(KeyXButton,SIGNAL(clicked()),this,SLOT(keyXClicked()));
    connect(KeyYButton,SIGNAL(clicked()),this,SLOT(keyYClicked()));
    connect(KeyZButton,SIGNAL(clicked()),this,SLOT(keyZClicked()));
    connect(KeySHIFTButton,SIGNAL(clicked()),this,SLOT(keySHIFTClicked()));
    connect(KeyCAPButton,SIGNAL(clicked()),this,SLOT(keyCAPClicked()));
    connect(KeyBACKSPACEButton,SIGNAL(clicked()),this,SLOT(keyBACKSPACEClicked()));
    connect(Key123Button,SIGNAL(clicked()),this,SLOT(key123Clicked()));
    connect(KeyPERIODButton,SIGNAL(clicked()),this,SLOT(keyPERIODClicked()));
    connect(KeyCOMMAButton,SIGNAL(clicked()),this,SLOT(keyCOMMAClicked()));
    connect(KeyHYPHENButton,SIGNAL(clicked()),this,SLOT(keyHYPHENClicked()));
    connect(KeySPACEButton,SIGNAL(clicked()),this,SLOT(keySPACEClicked()));

    timer->start(1000);
}
void GV_NameChangeDialog::reloadtext()
{
    //NameHintsLabel->setText(tr("Zones"));
}
void GV_NameChangeDialog::GV_chTime()
{
    TimeHintsLabel->setText((QDateTime::currentDateTime().toString("hh:mm:ss")));
    DateHintsLabel->setText((QDateTime::currentDateTime().toString("yyyy-MM-dd")));
}

void GV_NameChangeDialog::cancel()
{
    QDialog *dialog1 = new GV_SetupHomeDialog;
    dialog1->show();
    delete dialog;
    dialog = dialog1;
}



void GV_NameChangeDialog::save()
{
    //QString str;
    //str = "new:" + QString::number(newpassword) + "conform:" + QString::number(conformpassword);
    //QMessageBox::about(this, "value",str);

        QDialog *dialog1;
        dialog1 = new GV_SetupHomeDialog;
        dialog1->show();
        delete dialog;
        dialog = dialog1;


}

void GV_NameChangeDialog::showNumber()
{
   // if(totalNum < 1000000000){
        totalNum = totalNum*10 + currentNum;
      //  PasswordSetupChangePWDLCD->display(totalNum);
        if(newpasswodButtonEnable){
            newpassword = totalNum;
        }else{
            conformpassword = totalNum;
        }
    //}
}
void GV_NameChangeDialog::key0Clicked()
{
    currentNum = '0';
    showNumber();
}
void GV_NameChangeDialog::key1Clicked()
{
    currentNum = '1';
    showNumber();
}

void GV_NameChangeDialog::key2Clicked()
{
    currentNum = '2';
    showNumber();
}
void GV_NameChangeDialog::key3Clicked()
{
    currentNum = '3';
    showNumber();
}
void GV_NameChangeDialog::key4Clicked()
{
    currentNum = '4';
    showNumber();
}
void GV_NameChangeDialog::key5Clicked()
{
    currentNum = '5' ;
    showNumber();
}
void GV_NameChangeDialog::key6Clicked()
{
    currentNum = '6';
    showNumber();
}
void GV_NameChangeDialog::key7Clicked()
{
    currentNum = '7';
    showNumber();
}
void GV_NameChangeDialog::key8Clicked()
{
    currentNum = '8';
    showNumber();
}
void GV_NameChangeDialog::key9Clicked()
{
    currentNum = '9';
    showNumber();
}
void GV_NameChangeDialog:: keyAClicked()
{
    currentNum = 'A';
    showNumber();
}
void GV_NameChangeDialog:: keyBClicked()
{
    currentNum = 'B';
    showNumber();
}
void GV_NameChangeDialog:: keyCClicked()
{
    currentNum = 'C';
    showNumber();
}
void GV_NameChangeDialog:: keyDClicked()
{
    currentNum = 'D';
    showNumber();
}
void GV_NameChangeDialog:: keyEClicked()
{
    currentNum = 'E';
    showNumber();
}
void GV_NameChangeDialog:: keyFClicked()
{
    currentNum = 'F';
    showNumber();
}
void GV_NameChangeDialog:: keyGClicked()
{
    currentNum = 'G';
    showNumber();
}
void GV_NameChangeDialog:: keyHClicked()
{
    currentNum = 'H';
    showNumber();
}
void GV_NameChangeDialog:: keyIClicked()
{
    currentNum = 'I';
    showNumber();
}
void GV_NameChangeDialog:: keyJClicked()
{
    currentNum = 'J';
    showNumber();
}
void GV_NameChangeDialog:: keyKClicked()
{
    currentNum = 'K';
    showNumber();
}
void GV_NameChangeDialog:: keyLClicked()
{
    currentNum = 'L';
    showNumber();
}
void GV_NameChangeDialog:: keyMClicked()
{
    currentNum = 'M';
    showNumber();
}
void GV_NameChangeDialog:: keyNClicked()
{
    currentNum = 'N';
    showNumber();
}
void GV_NameChangeDialog:: keyOClicked()
{
    currentNum = 'O';
    showNumber();
}
void GV_NameChangeDialog:: keyPClicked()
{
    currentNum = 'P';
    showNumber();
}
void GV_NameChangeDialog:: keyQClicked()
{
    currentNum = 'Q';
    showNumber();
}
void GV_NameChangeDialog:: keyRClicked()
{
    currentNum = 'R';
    showNumber();
}
void GV_NameChangeDialog:: keySClicked()
{
    currentNum = 'S';
    showNumber();
}
void GV_NameChangeDialog:: keyTClicked()
{
    currentNum = 'T';
    showNumber();
}
void GV_NameChangeDialog:: keyUClicked()
{
    currentNum = 'U';
    showNumber();
}
void GV_NameChangeDialog:: keyVClicked()
{
    currentNum = 'V';
    showNumber();
}
void GV_NameChangeDialog:: keyWClicked()
{
    currentNum = 'W';
    showNumber();
}
void GV_NameChangeDialog:: keyXClicked()
{
    currentNum = 'X';
    showNumber();
}
void GV_NameChangeDialog:: keyYClicked()
{
    currentNum = 'Y';
    showNumber();
}
void GV_NameChangeDialog:: keyZClicked()
{
    currentNum = 'Z';
    showNumber();
}

void GV_NameChangeDialog:: keySPACEClicked()
{
    currentNum = ' ';
    showNumber();
}
void GV_NameChangeDialog:: keyHYPHENClicked()
{
    currentNum = '-';
    showNumber();
}
void GV_NameChangeDialog:: keyCOMMAClicked()
{
    currentNum = ',';
    showNumber();
}
void GV_NameChangeDialog:: keyPERIODClicked()
{
    currentNum = '.';
    showNumber();
}
void GV_NameChangeDialog:: keyCAPClicked()
{
    currentNum = '9';
    showNumber();
}
void GV_NameChangeDialog:: keySHIFTClicked()
{
    currentNum = '9';
    showNumber();
}
void GV_NameChangeDialog:: keyBACKSPACEClicked()
{
    currentNum = '9';
    showNumber();
}
void GV_NameChangeDialog:: key123Clicked()
{
    currentNum = '9';
    showNumber();
}


